package com.usercar.controller;

import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Calendar;

@RestController
@RequestMapping("carToCar")
@Api("车辆差额计算接口")
public class CarToCarController {
    @Autowired
    private EvaluationController evaluationController;

    /*@Autowired
    private CarMessageMentFeign carMessageMentFeign;*/
    @ApiOperation("车辆置换-旧车")
    @GetMapping("{pipai}/{chexi}/{nianfen}/{kuanshi}")
    public Result getAccount(@PathVariable("pipai")String pipai, @PathVariable("chexi")String chexi, @PathVariable("nianfen")String nianfen, @PathVariable("kuanshi")String kuanshi){
        //根据年份计算到今年的差额
        String substring = nianfen.substring(0, nianfen.length() - 1);
        int i = Calendar.getInstance().get(Calendar.YEAR);
        int i1 = Integer.parseInt(substring);
        Integer time = i1-i;
        Result r = evaluationController.getEvaluationPrice(pipai,chexi,nianfen,kuanshi,0,"黑色",time,15,"高配");
        String data =(String)r.getData();
        return Result.buildResult(ResultEnum.SUCCESS).setData(data);
    }

    @ApiOperation("车辆置换-意向车")
    @GetMapping("/{messageId}")
    public Result getMessage(@PathVariable("messageId")Long messageId){
        /*CarMessageDTO c = carMessageMentFeign.toSelectById(messageId);
        BigDecimal b = c.getPrice();
        return Result.buildResult(ResultEnum.SUCCESS).setData(b);*/
        return null;
    }

}
